﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using BEPUphysicsDrawer.Models;
using BEPUphysics.Entities;

namespace MagicArenaFramework.GameObject.Components.ConcreteTypes
{
    /// <summary>
    /// Renders the Model at the local of the entity
    /// </summary>
    public class EntityModelRender : GoComponent
    {
        public Entity Entity { get; private set; }
        public Model Model { get; private set; }
        
        private DisplayEntityModel meshShape;

        public EntityModelRender(Entity entity, Model model, ModelDrawer drawer)
        {
            Entity = entity;
            Model = model;
            meshShape = new DisplayEntityModel(Entity, Model, drawer);
        }

        public override bool isActive
        {
            get
            {
                return base.isActive;
            }
            set
            {
                if (value != isActive)
                {
                    if (value == true) meshShape.ModelDrawer.Add(meshShape);
                    else meshShape.ModelDrawer.Remove(meshShape);
                }
                
                base.isActive = value;
            }
        }
    }
}
